package com.atdel.demo10;


/**
 * @BelongsProject: java_study
 * @BelongsPackage: demo10
 * @Author: Del
 * @CreateTime: 2025-03-11  11:23
 * @Description: TODO
 * @Version: 1.0
 */
public class MyThread extends Thread {
    public MyThread() {
    }

    /**
     * 注意：在 Thread 中，存在 name 属性，用于表示线程的名称
     *
     * @param name 线程名称
     */
    public MyThread(String name) {
        super(name);
    }

    @Override
    public void run() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                System.out.println(Thread.currentThread().getName() + "： 采集数据");
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                // 重新设置中断标志
                Thread.currentThread().interrupt();
            }
        }
    }
}
